//
//  ZXStatusOriginalView.m
//  ZXOCWeiBo
//
//  Created by mac on 15/12/10.
//  Copyright © 2015年 itcast. All rights reserved.
//

#import "ZXStatusOriginalView.h"
#import "ZXStatusPhotosVIew.h"

@interface ZXStatusOriginalView()

@property(nonatomic,weak)UIImageView* avatorImgView;
@property(nonatomic,weak)UILabel * nickNameLabel;
@property(nonatomic,weak)UILabel * timeLabel;
@property(nonatomic,weak)UILabel * sourceLabel;
@property(nonatomic,weak)UILabel * textLabel;
@property(nonatomic,weak)UIImageView * vipImgView;
@property(nonatomic,weak)ZXStatusPhotosVIew * photosView;



@end

@implementation ZXStatusOriginalView


-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        //头像
        UIImageView * imgView = [[UIImageView alloc]init];
        [self addSubview:imgView];
        self.avatorImgView = imgView;
        //昵称
        UILabel *nickNameLabel = [[UILabel alloc]init];
        nickNameLabel.font = ZXStatusOrginlNameFont;
        [self addSubview:nickNameLabel];
        self.nickNameLabel = nickNameLabel;
        
        //时间
        UILabel *timeLabel = [[UILabel alloc]init];
        timeLabel.font = ZXStatusOrginlTimeFont;
       
        [self addSubview:timeLabel];
        self.timeLabel = timeLabel;
        
        //来源
        UILabel *sourceLabel = [[UILabel alloc]init];
        sourceLabel.font = ZXStatusOrginlTimeFont;
        [self addSubview:sourceLabel];
        self.sourceLabel = sourceLabel;
        
        //正文
        UILabel *textLabel = [[UILabel alloc]init];
        textLabel.font = ZXStatusOrginlTextFont;
//        textLabel.backgroundColor = [UIColor purpleColor];
        textLabel.numberOfLines = 0;
        [self addSubview:textLabel];
        self.textLabel = textLabel;
        
        //会员
        UIImageView * vipImgView = [[UIImageView alloc]init];
        [self addSubview:vipImgView];
        self.vipImgView = vipImgView;
        
//        配图
        ZXStatusPhotosVIew * photosView = [[ZXStatusPhotosVIew alloc]init];
        [self addSubview:photosView];
        self.photosView = photosView;
        
//        self.backgroundColor = [UIColor brownColor];
    }
    return self;
}

-(void)setOriginalFrm:(ZXStatusOriginalFrm *)originalFrm
{
    _originalFrm = originalFrm;
    // 微博模型
    ZXStatuses * statuses = originalFrm.statuses;
    
//    设置自身的frm
    self.frame = originalFrm.selfFrm;
    
//    设置头像
    self.avatorImgView.frame = originalFrm.avatarFrm;
    NSURL * imgUrl = [NSURL URLWithString:statuses.user.profile_image_url];
    [self.avatorImgView sd_setImageWithURL:imgUrl];
    
//    设置昵称
    self.nickNameLabel.frame = originalFrm.nameFrm;
    self.nickNameLabel.text = statuses.user.screen_name;
    
//    1.设置会员
    self.vipImgView.frame = originalFrm.vipFrm;
    if (statuses.user.isVip)
    {
        self.vipImgView.hidden = NO;
        NSString * vipLevelImg = [NSString stringWithFormat:@"common_icon_membership_level%d",statuses.user.mbrank];
        
        //    2.会员等级
        self.vipImgView.image = [UIImage imageNamed:vipLevelImg];
    }
    else
    {
        self.vipImgView.hidden = YES;
    }

    
//    设置时间
    self.timeLabel.frame = originalFrm.timeFrm;
    self.timeLabel.text = statuses.created_at;
    
//    设置来源
    self.sourceLabel.frame = originalFrm.sourceFrm;
    self.sourceLabel.text = statuses.source;
    
//    设置正文
    self.textLabel.frame = originalFrm.textFrm;
    self.textLabel.text = statuses.text;
    
//    设置配图
    self.photosView.frame = originalFrm.photosFrm;
//    self.photosView.backgroundColor = [UIColor purpleColor];
//    设置图片的显示
    self.photosView.pic_urls = originalFrm.statuses.pic_urls;
    
}
@end
